<?php require_once('../../core/import.php');?>
<?php User::Permission('ACCOUNT_LIST'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=8" />
    <script type="text/javascript" src="../../scripts/import.js"></script>
    <script type="text/javascript" src="../../scripts/components/checkbox/import.checkbox.js"></script>
    <script type="text/javascript" src="../../scripts/components/zebra_table/import.zebra_table.js"></script>
    <script type="text/javascript" src="scripts/list.js"></script>
</head>

<body>
<?php  
	 $Keyword = Functions::HttpArgs('Keyword');
	 $Login_Count= Functions::HttpArgs('Login_Count');
	 $Keyword_first = Functions::HttpArgs('Keyword_first');
	 $Location=Functions::UrlArgs('location');
?>
  <form id="Form_select" name="Form_select" method="post" action="list.php?location=<?php echo $Location;  ?>">
    <table width="98%" border="0" cellpadding="0" cellspacing="0" class="List">
    <thead>
    <tr>
        <th width="20%" height="25" align="right" valign="middle">公司名称(或用户名)：&nbsp; </th>
        <th width="20%" height="25" align="left" valign="middle"><input name="Keyword" type="text" size="40" /></th>
        <th width="40%" height="25" align="right" valign="middle">
        <input name="Keyword_first" type="hidden" value="<?php echo $Keyword?>" />
        <input type="button" onclick="window.location='list.php?location=<?php echo $Location;?>';" value="返回列表" /></th>
        <th width="20%" height="25" align="center" valign="middle"><input type="submit" value="搜 索" /></th>
    </tr>
    </thead>
    </table>
</form>
    <table width="98%" id="List" border="0" cellpadding="0" cellspacing="0" class="List">
    <thead>
    <tr>
        <th width="2%" height="25" align="center" valign="middle">选</th>
        <th width="35%" align="left" valign="middle">&nbsp;用户名</th>
        <th width="24%" align="left" valign="middle">公司名称</th>
        <th width="12%" align="center" valign="middle">注册人</th>
        <th width="11%" align="center" valign="middle">注册时间</th>
        <th width="10%" align="center" valign="middle"><a href="list.php?location=<?php echo $Location; ?>&Login_Count=yes">登陆次数</a></th>
        <th width="6%" align="center" valign="middle">操作</th>
    </tr>
    </thead>    
    <tbody>
    <form id="Form1" name="Form1" method="post" action="list.action.batch_delete.php">
    <?php
        #获取数据
	 
	  $Where_This=' Username not in (select Account from `account_delete` where Account is not null )';
	  $Order_This=' order by Datetime desc ';
	  if($Keyword)
	  {
		  $Where_This=$Where_This." and (CompanyName like '%$Keyword%' or Username like '%$Keyword%')";
	  }
	  if($Keyword_first)
	  {
		  $Where_This=$Where_This." and (CompanyName like '%$Keyword_first%' or Username like '%$Keyword_first%')";
	  }
	  if($Login_Count)
	  {
		  $Order_This=' order by Login_Count desc ';
	  }
	  $Data=DB::GetData('select ID,Username,CompanyName,Datetime,Login_Datetime,M_IsTop,Login_Count  from `account` where '.$Where_This.$Order_This.' limit ?,15');
        foreach($Data['Record'] as $Row)
        {
    ?>
    <tr>
        <td height="25" align="center" valign="middle">
            <input id="ID" name="ID[]" type="checkbox" value="<?php echo $Row['ID']; ?>" class="Cursor_Pointer" />
        </td>
        <td height="25" valign="middle">
         <?php 
	  	$Title_Len=60;
		$data_email=DB::GetRows('select Account from `account_email_verification` where Account=\''.$Row['Username'].'\'');
		$data_locked=DB::GetRows('select Account from `account_locked` where Account=\''.$Row['Username'].'\'');
		$data_vip=DB::GetRows('select Account from `account_vip` where Account=\''.$Row['Username'].'\'');
		$data_integrity=DB::GetRows('select Account from `account_integrity` where Account=\''.$Row['Username'].'\'');
		if($Row['M_IsTop'])
		{
			echo '<font color="red">【置顶】</font>';
			$Title_Len=$Title_Len-4;
		}
		if(count($data_email)>0)
		{
			echo '<font color="orange">【验证】</font>';
			$Title_Len=$Title_Len-4;
		}
		if(count($data_vip)>0)
		{
			echo '<font color="Olive">【vip】</font>';
			$Title_Len=$Title_Len-4;
		}
		if(count($data_integrity)>0)
		{
			echo '<font color="Maroon">【诚信】</font>';
			$Title_Len=$Title_Len-4;
		}
		if(count($data_locked)>0)
			{
				echo '<font color="MidnightBlue">【锁定】</font>';
				$Title_Len=$Title_Len-4;
			}
	   ?>
            &nbsp;<a href="http://ancillary.shipinall.cn/store/<?php echo $Row['ID']; ?>/index.html" target="_blank"><?php echo Functions::SubStr($Row['Username'],$Title_Len); ?></a>
        </td>
         <td height="25" valign="middle">
            &nbsp;<?php echo Functions::SubStr($Row['CompanyName'],50); ?>
        </td>
        <td height="25" align="center" valign="middle">
            <?php 
			$Registration=DB::GetRows('select User from `management_user_register` where Account=\''.$Row['Username'].'\'');
			if($Registration)
			{
				echo '<font color="red">'.$Registration[0]['User'].'</font>';
			}
			else
			{
				echo '<font color="green">自注册</font>';
			}
			
		?>
        </td>
        <td height="25" align="center" valign="middle" title="<?php echo '最后登录时间为：'.$Row['Login_Datetime'];?>">
            <?php echo $Row['Datetime']?>
        </td>
        <td height="25" align="center" valign="middle" >
            <?php echo $Row['Login_Count']?>
        </td>
        <td height="25" align="center" valign="middle">
            <a href="edit.php?<?php echo 'id='.$Row['ID'].'&location='.$Location; ?>">编辑</a>
            <a href="javascript:mconfirm_delete('list.action.delete.php?id=<?php echo $Row['ID']?>');">删除</a>
        </td>
    </tr>
    <?php
        }
    ?>
    </form>
    </tbody>    
    <tfoot>
    <tr>
        <td height="25" colspan="7" align="center" valign="middle">
            <table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
                <td width="55%" align="left">
                <?php
                    PagerFactory::Create('Simple')->Display($Data,array
			  (
			  	'Parameters'=>array(
					'Keyword'=>$Keyword,
					'location'=>$Location,
					'Login_Count'=>$Login_Count
					)
			  ));
                ?>
                </td>
                <td width="45%" align="right">
                    <span id="SelectAll" class="Cursor_Pointer">全选</span>/<span id="UnSelectAll" class="Cursor_Pointer">全不选</span>
                    选中项：
                    <span id="Delete" class="Cursor_Pointer">删除</span>&nbsp;
                    <span id="IsTop" class="Cursor_Pointer"><font color="red">置顶</font></span>&nbsp;
                    <span id="Email" class="Cursor_Pointer"><font color="orange">验证</font></span>&nbsp;    
                    <span id="Vip" class="Cursor_Pointer"><font color="Olive">VIP</font></span>&nbsp;
                    <span id="Integrity" class="Cursor_Pointer"><font color="Maroon">诚信</font></span>&nbsp;
                    <span id="Locked" class="Cursor_Pointer"><font color="MidnightBlue">锁定</font></span>         
                </td>
            </tr>
            </table>    
         </td>
	</tr>
    </tfoot>    
    </table>
</body>
</html>